Date.prototype.pattern=function(fmt) {          

    var o = {          

    "M+" : this.getMonth()+1, //月份          

    "d+" : this.getDate(), //日          

    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时          

    "H+" : this.getHours(), //小时          

    "m+" : this.getMinutes(), //分          

    "s+" : this.getSeconds(), //秒          

    "q+" : Math.floor((this.getMonth()+3)/3), //季度          

    "S" : this.getMilliseconds() //毫秒          

    };          

    var week = {          

    "0" : "\u65e5",          

    "1" : "\u4e00",          

    "2" : "\u4e8c",          

    "3" : "\u4e09",          

    "4" : "\u56db",          

    "5" : "\u4e94",          

    "6" : "\u516d"         

    };          

    if(/(y+)/.test(fmt)){          

        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));          

    }          

    if(/(E+)/.test(fmt)){          

        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "\u661f\u671f" : "\u5468") : "")+week[this.getDay()+""]);          

    }          

    for(var k in o){          

        if(new RegExp("("+ k +")").test(fmt)){          

            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));          

        }          

    }          

    return fmt;          

} 

//公共方法
var buildUrl = function(type, module, method,customerId,params,str) {
	 if(!str)str="";
		params = encodeURIComponent(JSON.stringify(params));
		var _URL = "call." + type + '?module=' + module + '&customerId='+customerId+'&method=' + method+'&params=' + params +str;
		return _URL;
	}

var formartFormData=function(selector) {
        var el = typeof selector == "string" ? $(selector) : $(selector[0], selector[1]);
        var formData = el.serializeArray(),
            formDataJson = {};
        $.each(formData, function(index, val) {
            if (val.value) formDataJson[val.name] = val.value;
        });

        return formDataJson;
  }
//iframe加载完成公共方法适应高度
function iframeLoad(_class){
	layer.closeAll();
	var height=document.documentElement.clientHeight,
		width=document.documentElement.clientWidth;
	console.log(document.getElementsByClassName(_class));
	document.getElementsByClassName(_class)[0].style.display='block';
	document.getElementsByClassName(_class)[0].style.width=width+'px';
	document.getElementsByClassName(_class)[0].style.height=height+'px';
}

//文档的总高度
function getScrollHeight() {
		var scrollHeight = 0,
			bodyScrollHeight = 0,
			documentScrollHeight = 0;
		if (document.body) {
			bodyScrollHeight = document.body.scrollHeight;
		}
		if (document.documentElement) {
			documentScrollHeight = document.documentElement.scrollHeight;
		}
		scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
		return scrollHeight;
	}

function getWindowHeight() {　　
		var windowHeight = 0;　　
		if (document.compatMode == "CSS1Compat") {　　　　
			windowHeight = document.documentElement.clientHeight;　　
		} else {　　　　
			windowHeight = document.body.clientHeight;　　
		}　　
		return windowHeight;
	}

function getScrollTop() {　　
	var scrollTop = 0,
		bodyScrollTop = 0,
		documentScrollTop = 0;　　
	if (document.body) {　　　　
		bodyScrollTop = document.body.scrollTop;　　
	}　　
	if (document.documentElement) {　　　　
		documentScrollTop = document.documentElement.scrollTop;　　
	}　　
	scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;　　
	return scrollTop;
}


function getsec(str)
{ 
   var str1=str.substring(1,str.length)*1; 
   var str2=str.substring(0,1);
   if (str2=="s")
   { 
        return str1*1000; 
   }
   else if (str2=="h")
   { 
       return str1*60*60*1000; 
   }
   else if (str2=="d")
   { 
       return str1*24*60*60*1000; 
   } 
} 
//设置cookies
function setCookie(name,value,time)
{ 
    var strsec = getsec(time);
   
    var exp = new Date(); 
    exp.setTime(exp.getTime() + strsec); 
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
} 
//读取cookies 
function getCookie(name) 
{ 
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
 
        return unescape(arr[2]); 
    else 
        return null; 
} 

//删除cookies 
function delCookie(name) 
{ 
    var exp = new Date(); 
    exp.setTime(exp.getTime() - 1); 
    var cval=getCookie(name); 
    if(cval!=null) 
        document.cookie= name + "="+cval+";expires="+exp.toGMTString(); 
} 
